#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
int T,n,m,L,V,cnt1,cnt2,mapp[N*10],vis[N*10];
struct node{
    int d,v,a,vis,dd;
    double x0;
}car[N];
int p[N];
double fun(int v0,int a){
    if(a==0) return 0;
    return (9-v0*v0)*1.0/(2*a)*1.0;
}
bool check_dis(int d,int x0){
    for(int i = d;i<=x0;i++){
        if(mapp[i]==1) return true;
    }
    return false;
}
bool cmp(node a,node b){
    return a.d<b.d;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        cnt1 = cnt2 = 0;
        memset(p,N,0);
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i = 1;i<=n;i++) car[i].vis = car[i].dd = 0;
        for(int i = 1;i<=n;i++) scanf("%d%d%d",&car[i].d,&car[i].v,&car[i].a);
        for(int i = 1;i<=m;i++) {scanf("%d",&p[i]);mapp[p[i]]=1;}
        for(int i = 1;i<=n;i++){
            if(car[i].v<=V&&car[i].a<=0) continue;
            if(car[i].v>V&&car[i].a>=0&&car[i].d<=p[m]){
                cnt1++;
                car[i].vis = 1;
                continue;}
            car[i].x0 = car[i].d+fun(car[i].v,car[i].a);
            if(car[i].v<V&&car[i].x0<=p[m]&&car[i].a>0){
                cnt1++;
                car[i].vis = 1;
                continue;
            }
            if(car[i].v>V&&check_dis(car[i].d,floor(car[i].x0))&&car[i].a<0){
                cnt1++;
                car[i].vis = 1;
                continue;
            }
        }
        printf("%d ",cnt1);
        sort(car+1,car+1+n,cmp);
        for(int i = 1;i<n;i++){
            if(car[i].vis==1){
                for(int j = 1;j<=m;j++){
                    if(p[j]>=car[i+1].d&&p[j]<car[i].x0&&car[i+1].dd!=1){
                        car[i].dd = 1;
                        car[i+1].dd = 1;
                        cnt2++;
                    }
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(car[i].vis==1&&car[i].dd!=1){
                cnt2++;
            }
        }
        printf("%d\n",cnt2);
    }
    return 0;
}
